/*
 * @Description:
 * @Author:Huang Xin Ming
 * @Date:2024-11-07 10:41:01
 * @LastEditors:Huang Xin Ming
 * @LastEditTime:2024-11-11 17:11:23
 */
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import type { UserInfoInterface } from '@/api/types/user'
export const useUserStore = defineStore('user',() => {
    const Token = ref<string>('')
    const USERINFO = ref<UserInfoInterface>()
    /**
     * @Description: 设置token
     * @return {*}
     * @author:Huang Xin Ming
     */
    const setToken = (token: string):void => {
        Token.value = token
    }
    const setUserInfo = (data:UserInfoInterface):void => {
        USERINFO.value = data
    }
    /**
     * @Description: 是否登录
     * @return {*}
     * @author:Huang Xin Ming
     */    
    const isLogin = computed(() => {
        return Token.value && Token.value !== ''
    })
    return {
        Token,
        isLogin,
        setToken,
        setUserInfo,
    }
},{
    persist: true,
})
